package org.wat.wcy.isi.mmazur.bp.io.xpdl.generator;

import org.wat.wcy.isi.mmazur.bp.io.model.IdDesc;

public class IdGenerator {
	
	private int id = 1;
	
	synchronized public String next() {
		return generateId(id++);
	}

	private String generateId(int k) {
		String newId = Integer.toString(k);
		StringBuilder strb = new StringBuilder();
		int start = IdDesc.ID_NULL.length() - newId.length();
		int index = 0;
		for (int i = 0; i < IdDesc.ID_NULL.length(); i++) {
			if (i == 8 || i == 13 || i == 18 || i == 23) {
				strb.append("-");
			} else if (i >= start){
				strb.append(newId.charAt(index++));
			} else {
				strb.append(0);
			}
		}
		return strb.toString();
	}
}
